$(function() {
	$('.add').on('click', function() {
		var rulemain = $('.rule').html()
		rulemain += `<div class="am-u-sm-12 cl-p " style="margin-bottom: 5px;">
							<div class="am-u-sm-6 cl-p" >
								<div class="am-u-sm-6 ">
									<input type="text" name='start_date' class="am-form-field tpl-form-no-bg start_date" placeholder="开始时间"  readonly="">
								</div>
								<div style="position: absolute;left: 50%;margin-left: -5px;">~</div>
								<div class="am-u-sm-6">
									<input type="text" name='end_date'  class="am-form-field tpl-form-no-bg end_date" placeholder="结束时间"  readonly="">
								</div>
							</div>
							<div class="am-u-sm-6 cl-p">
								<label for="user-name" class="am-u-sm-3 am-form-label">赠送金额 </label>
								<div class="am-u-sm-6">
									<input type="text" class="tpl-form-input" id="user-name" placeholder="">
								</div>
								<div class="am-u-sm-3 "><button type="button" class="am-btn-sm am-btn-danger am-radius delect">删除</button></div>
							</div>
						</div>`
		$('.rule').html(rulemain)
		$('.end_date').datepicker()
		$('.start_date').datepicker()
		$('.delect').on('click', function() {
			if($('.rule').children().length > 1) {
				$(this).parent().parent().parent().remove()
			}else{
				layer.open({
				  title: '提示'
				  ,content: '至少需要一条规则'
				  ,btn:['关闭']
				});  
			}
		})
	})
	$('.delect').on('click', function() {
		var that=this
		if($('.rule').children().length > 1) {
			$(this).parent().parent().parent().remove()
		}else{
			layer.open({
			  title: '提示'
			  ,content: '至少需要一条规则'
			  ,btn:['关闭']
			});    
		}
	})
})